package com.lanchetech.dao;

import com.lanchetech.bean.vo.DividendPrecipitationVO;
import com.lanchetech.entity.DividendPrecipitation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Mapper
public interface DividendPrecipitationMapper {
    int deleteByPrimaryKey(Long id);

    int insert(DividendPrecipitation record);

    int insertSelective(DividendPrecipitation record);

    DividendPrecipitation selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(DividendPrecipitation record);

    int updateByPrimaryKey(DividendPrecipitation record);

    DividendPrecipitation findOneByTypeAndWeekTime(@Param("type") Byte type, @Param("weekTime") Date weekTime);

    int updateDividendPrecipitation(@Param("updatedCount") Integer updatedCount, @Param("updatedAmount") BigDecimal updatedAmount, @Param("updatedCommission") BigDecimal updatedCommission, @Param("updatedUpdatedAt") Date updatedUpdatedAt, @Param("id") Long id);

    List<DividendPrecipitation> findAllByWeekTimeAndStatus(@Param("weekTime") Date weekTime, @Param("status") Byte status);

    DividendPrecipitation findOneByTypeAndStatusAndWeekTime(@Param("type") Byte type, @Param("status") Byte status, @Param("weekTime") Date weekTime);

    int updateStatusAndUpdatedAtByWeekTimeAndType(@Param("updatedStatus") Byte updatedStatus, @Param("updatedUpdatedAt") Date updatedUpdatedAt, @Param("weekTime") Date weekTime, @Param("type") Byte type);

    List<DividendPrecipitationVO> findAllByTypeAndWeekTimeRange(@Param("type") Byte type, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    DividendPrecipitation sumAllByType(@Param("type") Byte type);

    int updateDividendCountAndUpdatedAtById(@Param("updatedDividendCount") Integer updatedDividendCount, @Param("updatedUpdatedAt") Date updatedUpdatedAt, @Param("id") Long id);

    DividendPrecipitationVO getStaticDividendDetail(@Param("type") Byte type, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    DividendPrecipitation findLastOne(@Param("type") Byte type);

    List<DividendPrecipitation> findNotGiveWeek(@Param("date") Date date, @Param("status") Byte status);

    List<DividendPrecipitation> findNotGiveWeekAndType(@Param("date") Date date, @Param("status") Byte status, @Param("type") Byte type);

    int updateStatusAndUpdatedAtByWeekTimeBeforeAndTypeAndStatus(@Param("updatedStatus") Byte updatedStatus, @Param("updatedUpdatedAt") Date updatedUpdatedAt, @Param("maxWeekTime") Date maxWeekTime, @Param("type") Byte type, @Param("status") Byte status);


}